Skip to content

perf(spdk): replace sector division with cached shifts - #30

Merged
thweetkomputer merged 1 commit into
eloqdata:mainfrom
thweetkomputer:perf/spdk-sector-arithmetic
Nov 3, 2026
Merged

thweetkomputer merged 1 commit into
eloqdata:mainfrom
thweetkomputer:perf/spdk-sector-arithmetic

Conversation

@thweetkomputer

Copy link
Copy Markdown
Contributor

SPDK submission currently uses variable division and remainder for sector alignment and LBA conversion even though device discovery already accepts only nonzero power-of-two sector sizes. Cache the sector exponent during discovery, then use a mask for alignment and shifts for LBA/count conversion in synchronous metadata I/O and asynchronous worker I/O.

Existing device validation, request-size limits, overflow-safe range checks, queue ordering and completion semantics remain unchanged. Seven new stub cases cover synchronous/asynchronous conversion with 1-, 512- and 4096-byte sectors, malformed sector sizes, queued requests, offsets beyond 32 bits, exact device-end requests, misalignment and overflow rejection.

Validation from the Bycorf repository:

cmake --build build-testcases-bypass --parallel 4
ctest --test-dir build-testcases-bypass --output-on-failure
pre-commit run --files src/io/spdk_storage.cpp tests/spdk_backpressure_stub_test.cpp

The existing build uses CMAKE_BUILD_TYPE=Debug, BYCORF_BUILD_EXAMPLES=OFF and BYCORF_KERNEL_BYPASS=ON. All 130 tests passed. Formatting and whitespace checks passed.

GCC 13.3/AArch64 -O3 assembly has zero variable divisions in the inspected synchronous submission and four asynchronous read/write entry points, versus two per function before. The synchronous whole-function instruction count stays 152; asynchronous read/read-fixed counts fall from 84 to 83 and write/write-fixed from 85 to 84. This is static code-generation evidence, not a hardware throughput or latency measurement.

Cache the exponent after validating a power-of-two sector size. Use masks for alignment and shifts for synchronous and asynchronous LBA conversion, retaining existing range and result-size checks.

Validated 130 bypass-capable tests, including new 1/512/4096-byte sector cases, queued conversions, exact device-end requests, malformed sector sizes and overflow rejection. GCC 13 AArch64 O3 assembly removes both variable divisions from the inspected submission functions.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 130d5299-eca1-42fd-a8f8-cf7969a57e03
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@thweetkomputer
thweetkomputer merged commit 6deaac5 into eloqdata:main Nov 3, 2026
10 checks passed
@thweetkomputer
thweetkomputer deleted the perf/spdk-sector-arithmetic branch November 3, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant